import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import '@/styles/vant.less' // 覆盖vant的默认样式
import '@/styles/index.less' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // svg icon
import '@/assets/iconfont/iconfont.css' // font-class icon
import '@/permission' // permission control
import 'lib-flexible'

import * as filters from './filters' // global filters
import md5 from 'js-md5'
Vue.prototype.$md5 = md5

import mixin from '@/utils/mixin'
Vue.mixin(mixin)

// 按需引入公共的vant组件
import { Icon, Button, Toast, Lazyload, Image as VanImage, Empty, Loading } from 'vant'
Toast.setDefaultOptions({ forbidClick: true })
Vue.use(Icon)
Vue.use(Button)
Vue.use(Toast)
Vue.use(VanImage)
Vue.use(Lazyload, {
  lazyComponent: true
})
Vue.use(Empty)
Vue.use(Loading)
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
if (process.env.NODE_ENV === 'production') {
  const { mockXHR } = require('../mock')
  mockXHR()
}

// register global utility filters
Object.keys(filters).forEach((key) => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: (h) => h(App)
})
